﻿@{
    ViewBag.Title = "ParentElement";
    Layout = "~/Views/Shared/_Page.cshtml";
}

<style type="text/css">
	table {
		border:3px double green;
	}
</style>

<h2>Parent Element</h2>

<table id="tblEmployee">
	<tr>
		<td>Employee Name</td><td>Department Name</td><td>Salary</td>
	</tr>
	<tr>
		<td>Jane Smith</td><td>Marketing</td><td>$95,000</td>
	</tr>
	<tr>
		<td>John Smith</td><td>Technology</td><td>$90,000</td>
	</tr>
	<tr>
		<td>Brian Adam</td><td>Sales</td><td>$72,000</td>
	</tr>
	<tr>
		<td>Mary Jones</td><td>Support</td><td>$60,000</td>
	</tr>
	<tr>
		<td>Michael Jefferson</td><td>Technology</td><td>$85,000</td>
	</tr>
</table><br>
   
<input id="btnTestIt" type="button" value="Test It">

<script type="text/javascript">
    $(document).ready(function () {
        $("#btnTestIt").click(function () {
            $("#tblEmployee td").each(function (index, htmlElement) {
                var cellValue = $(this).text();

                // if Department is Technology, do something
                if (cellValue == "Technology") {
                    $(this).parent().css("background-color", "green");
                }
            });
        });
    });
</script>
